<?php


namespace common\validate;


class ReviewRequest extends BaseValidate
{
    public $rule = [];

    // MyReviewList 验证场景定义
    public function sceneMyReviewList()
    {
        return $this->append("param", "array")
            ->append("param.filter.project_id", "integer")
            ->append("param.filter.submit_start", "datetime")
            ->append("param.filter.submit_end", "datetime")
            ->append("param.filter.review_start", "datetime")
            ->append("param.filter.review_end", "datetime");
    }

    // Create  验证场景定义
    public function sceneCreate()
    {
        return $this->append("data", "require|array")
            ->append("data.reviewers", "require|array")
            ->append("data.data", "require|array")
            ->append("data.data.review_workflow_id", "require|integer")
            ->append("data.data.name", "require|max:255")
            ->append("data.data.link_id", "require|integer")
            ->append("data.data.module_id", "require|integer")
            ->append("data.data.param", "array");
    }

    // Review  验证场景定义
    public function sceneReview()
    {
        return $this->append("data", "require|array")
            ->append("data.id", "require|integer")
            ->append("data.is_pass", "require|in:yes,no");
    }

    // BatchReviews  验证场景定义
    public function sceneBatchReviews()
    {
        return $this->append("id", "require|integer")
            ->append("is_pass", "require|in:yes,no");
    }

    // SelectMySubmittedReviewList  验证场景定义
    public function sceneSelectMySubmittedReviewList()
    {
        return $this->append("param.filter.is_reviewed", "in:yes,no")
            ->append("param.filter.submit_time", "array")
            ->append("param.filter.project_id", "integer")
            ->append("param.fields", "string")
            ->append("param.filter.review_time", "array");
    }

    // ReviewList 验证场景定义
    public function sceneReviewList()
    {
        return $this->append("param.filter", 'require')->append("param.module_code", 'require');
    }

    // GetReviewResult 验证场景定义
    public function sceneGetReviewResult()
    {
        return $this->append("param.filter.version_id", "require")
            ->append("param.filter.review_request_id", "integer|min:1");
    }

    // TaskRepairOrderReviewList 验证场景定义
    public function sceneTaskRepairOrderReviewList()
    {
        return $this->append("param.filter", 'array')
            ->append("param.module_code", 'require');
    }

    public function sceneReviewRequestParam()
    {
        return $this->append("is_pass", "in:yes,no")
            ->append("version_check_list_id", "integer")
            ->append('repair_step_category_id', 'integer');
    }

    public function sceneReviewRequestParamNote()
    {
        return $this
            ->append("link_id", "require|integer")
            ->append("module_id", "require|integer")
            ->append('type', 'in:text,video,audio')
//            ->append("version_check_list_id", "require|integer")
            ->append("version_id", "integer");
    }

    public function sceneBatchCreate()
    {
        return $this->append("data", "require|array");
    }

    public function sceneBatchCreateItem()
    {
        return $this->append("reviewers", "require|array")
            ->append("data", "require|array")
            ->append("data.review_workflow_id", "require|integer")
            ->append("data.name", "require|max:255")
            ->append("data.link_id", "require|integer")
            ->append("data.module_id", "require|integer")
            ->append("data.param", "array");
    }
}
